#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
#include<stdlib.h>
int* spiralOrder(int** matrix, int matrixSize, int* matrixColSize, int* returnSize) {
    matrixColSize = (int*)malloc(sizeof(int) * matrixSize * matrixSize);
    *returnSize = matrixSize * matrixSize;
    int x = 0, y = 0;
    int k = 0;
    while (k < (*returnSize))
    {
        matrixColSize[k++] = matrix[x][y];
        if (x == 0 && y < matrixSize - 1)
        {
            y++;
        }
        else if (x < matrixSize - 1 && y == matrixSize - 1)
        {
            x++;
        }
        else if (x == matrixSize - 1 && y <= matrixSize - 1)
        {
            y--;
        }
        else if (x <= matrixSize - 1 && y == 0)
        {
            x--;
        }
    }
    return matrixColSize;
}


int main()
{
	int arr[][3] = { {1,2,3},{4,5,6},{7,8,9} };
	int* p = spiralOrder(arr, 3, int* matrixColSize, int* returnSize)
}